package wonders.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import wonders.mapper.PersonMapper;
import wonders.mapper.UserMapper;
import wonders.pojo.Person;

import java.util.List;

@RestController
public class HelloController {

    @Autowired
    public PersonMapper personMapper;

    @Autowired
    public UserMapper userMapper;

    @RequestMapping("insert")
    public String insert(Person person) {
        personMapper.insert(person);
        return "success";
    }

    @RequestMapping("delete")
    public String delete(int id) {
        personMapper.delete(id);
        return "success";
    }

    @RequestMapping("selectById")
    public String selectById(int id) {
        return personMapper.selectById(id).toString();
    }

    @RequestMapping("selectAll")
    public String selectAll() {
        List<Person> people = personMapper.selectAll();
        return people.toString();
    }

    @RequestMapping("getUserById")
    public String getUserById(int id) {
        return userMapper.selectById(id).toString();
    }

}
